package com.gupao.jly521.pattern.abstractfactory;

import com.gupao.jly521.beanfactory.ExportData0Factory;
import com.gupao.jly521.beanfactory.ExportData1Factory;
import com.gupao.jly521.beanfactory.ExportData2Factory;
import com.gupao.jly521.entity.ExportDataBaseEntity;

/**
 * @author Jly
 * @date 2018/8/17  14:30
 */
public class AbstractFactory {

    /**
     *  根据名称匹配不同的导出对象
     * @date 2018/8/17 14:09
     * @author Jly
     * @param [name]
     * @return com.gupao.jly521.simple.entity.ExportDataBaseEntity
     */
    public ExportDataBaseEntity createEntity(String name){
        if (name.equals("Data0")){
            return new ExportData0Factory().getExportDataEntity();
        }else if (name.equals("Data1")) {
            return new ExportData1Factory().getExportDataEntity();
        }else if (name.equals("Data2")) {
            return new ExportData2Factory().getExportDataEntity();
        }
        return null;
    }

    public static void main(String[] args) {
        AbstractFactory factory = new AbstractFactory();
        ExportDataBaseEntity entity= factory.createEntity("Data1");
        System.out.println(entity.getCommonColumn());
    }

}
